<template>
  <div>
    <van-nav-bar title="修改收货地址" fixed placeholder left-arrow  @click-left="onClickLeft"/>
    
    <van-address-edit
      :area-list="areaList"
      :address-info="AddressInfo"
      show-set-default
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
    />

  </div>
</template>

<script>
import { Dialog } from "vant";
import { Toast } from "vant";
import { updateAddressApi } from "@/utils/api";
export default {
  data() {
    return {
      areaList: {
        province_list: {
          110000: "北京市",
          120000: "天津市",
          130000: "浙江省"
        },
        city_list: {
          110100: "北京市",
          120100: "天津市",
          130100: "杭州市"
        },
        county_list: {
          110101: "东城区",
          110102: "西城区",
          130101: "上城区",
          130102: "拱墅区",
          130103: "西湖区"
        }
      }
    };
  },

  components: {},

  computed: {
    AddressInfo() {
      return this.$store.state.updateAddress;
    }
  },

  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onSave(content) {
      Toast("save");
      console.log(content);
      // 修改用户信息
      updateAddressApi({
        token: localStorage.getItem("token"),
        addressId: content.addressId,
        getName: content.name,
        getPhone: content.tel,
        address: content.addressDetail,
        status: content.isDefault ? 1 : 2
      }).then(res => {
        Dialog.alert({
        message: res.msg
      }).then(() => {
        this.$router.go(-1);
      });
      });
    }
  }
};
</script>

<style lang="less" scoped></style>
